package com.jrzh.mvc.search.sys;

import org.apache.commons.lang.StringUtils;
import com.jrzh.framework.searchutils.Criteria;
import com.jrzh.framework.searchutils.Restrictions;
import com.jrzh.framework.base.search.BaseSearch;

public class TableFieldSearch extends BaseSearch{
	private static final long serialVersionUID = 1L;
	
    /**
     * Equal 表格ID
     */
    private String equalTableId;
    
    /**
     * Like 表格ID
     */
    private String likeTableId;
    
     /**
     * In 表格ID 英文逗号分隔
     */
    private String inTableIds;
    
    /**
     * Equal 字段key
     */
    private String equalFieldKey;
    
    /**
     * Like 字段key
     */
    private String likeFieldKey;
    
     /**
     * In 字段key 英文逗号分隔
     */
    private String inFieldKeys;
    
    /**
     * Equal 字段类型
     */
    private String equalFieldType;
    
    /**
     * Like 字段类型
     */
    private String likeFieldType;
    
     /**
     * In 字段类型 英文逗号分隔
     */
    private String inFieldTypes;
    
    /**
     * Equal 是否允许为空
     */
    private String equalIsNull;
    
    /**
     * Like 是否允许为空
     */
    private String likeIsNull;
    
     /**
     * In 是否允许为空 英文逗号分隔
     */
    private String inIsNulls;
    
    /**
     * Equal 默认值
     */
    private String equalDefault;
    
    /**
     * Like 默认值
     */
    private String likeDefault;
    
     /**
     * In 默认值 英文逗号分隔
     */
    private String inDefaults;
    
    /**
     * Equal 注释
     */
    private String equalComment;
    
    /**
     * Like 注释
     */
    private String likeComment;
    
     /**
     * In 注释 英文逗号分隔
     */
    private String inComments;
    

    public void setEqualTableId(String equalTableId) {
        this.equalTableId = equalTableId;
    }
    
    public String getEqualTableId() {
        return this.equalTableId;
    }
    
    public void setLikeTableId(String likeTableId) {
        this.likeTableId = likeTableId;
    }
    
    public String getLikeTableId() {
        return this.likeTableId;
    }
    
    public void setInTableIds(String inTableIds) {
        this.inTableIds = inTableIds;
    }
    
    public String getInTableIds() {
        return this.inTableIds;
    }
    public void setEqualFieldKey(String equalFieldKey) {
        this.equalFieldKey = equalFieldKey;
    }
    
    public String getEqualFieldKey() {
        return this.equalFieldKey;
    }
    
    public void setLikeFieldKey(String likeFieldKey) {
        this.likeFieldKey = likeFieldKey;
    }
    
    public String getLikeFieldKey() {
        return this.likeFieldKey;
    }
    
    public void setInFieldKeys(String inFieldKeys) {
        this.inFieldKeys = inFieldKeys;
    }
    
    public String getInFieldKeys() {
        return this.inFieldKeys;
    }
    public void setEqualFieldType(String equalFieldType) {
        this.equalFieldType = equalFieldType;
    }
    
    public String getEqualFieldType() {
        return this.equalFieldType;
    }
    
    public void setLikeFieldType(String likeFieldType) {
        this.likeFieldType = likeFieldType;
    }
    
    public String getLikeFieldType() {
        return this.likeFieldType;
    }
    
    public void setInFieldTypes(String inFieldTypes) {
        this.inFieldTypes = inFieldTypes;
    }
    
    public String getInFieldTypes() {
        return this.inFieldTypes;
    }
    public void setEqualIsNull(String equalIsNull) {
        this.equalIsNull = equalIsNull;
    }
    
    public String getEqualIsNull() {
        return this.equalIsNull;
    }
    
    public void setLikeIsNull(String likeIsNull) {
        this.likeIsNull = likeIsNull;
    }
    
    public String getLikeIsNull() {
        return this.likeIsNull;
    }
    
    public void setInIsNulls(String inIsNulls) {
        this.inIsNulls = inIsNulls;
    }
    
    public String getInIsNulls() {
        return this.inIsNulls;
    }
    public void setEqualDefault(String equalDefault) {
        this.equalDefault = equalDefault;
    }
    
    public String getEqualDefault() {
        return this.equalDefault;
    }
    
    public void setLikeDefault(String likeDefault) {
        this.likeDefault = likeDefault;
    }
    
    public String getLikeDefault() {
        return this.likeDefault;
    }
    
    public void setInDefaults(String inDefaults) {
        this.inDefaults = inDefaults;
    }
    
    public String getInDefaults() {
        return this.inDefaults;
    }
    public void setEqualComment(String equalComment) {
        this.equalComment = equalComment;
    }
    
    public String getEqualComment() {
        return this.equalComment;
    }
    
    public void setLikeComment(String likeComment) {
        this.likeComment = likeComment;
    }
    
    public String getLikeComment() {
        return this.likeComment;
    }
    
    public void setInComments(String inComments) {
        this.inComments = inComments;
    }
    
    public String getInComments() {
        return this.inComments;
    }

	@Override
	public void setCriterias(Criteria<?> criterias) {
	    if(StringUtils.isNotBlank(equalTableId)){
			criterias.add(Restrictions.eq("tableId", equalTableId));
		}
	    if(StringUtils.isNotBlank(likeTableId)){
			criterias.add(Restrictions.allLike("tableId", likeTableId));
		}
		 if(StringUtils.isNotBlank(inTableIds)){
			criterias.add(Restrictions.in("tableId", StringUtils.split(inTableIds, ",")));
		}
	    if(StringUtils.isNotBlank(equalFieldKey)){
			criterias.add(Restrictions.eq("fieldKey", equalFieldKey));
		}
	    if(StringUtils.isNotBlank(likeFieldKey)){
			criterias.add(Restrictions.allLike("fieldKey", likeFieldKey));
		}
		 if(StringUtils.isNotBlank(inFieldKeys)){
			criterias.add(Restrictions.in("fieldKey", StringUtils.split(inFieldKeys, ",")));
		}
	    if(StringUtils.isNotBlank(equalFieldType)){
			criterias.add(Restrictions.eq("fieldType", equalFieldType));
		}
	    if(StringUtils.isNotBlank(likeFieldType)){
			criterias.add(Restrictions.allLike("fieldType", likeFieldType));
		}
		 if(StringUtils.isNotBlank(inFieldTypes)){
			criterias.add(Restrictions.in("fieldType", StringUtils.split(inFieldTypes, ",")));
		}
	    if(StringUtils.isNotBlank(equalIsNull)){
			criterias.add(Restrictions.eq("isNull", equalIsNull));
		}
	    if(StringUtils.isNotBlank(likeIsNull)){
			criterias.add(Restrictions.allLike("isNull", likeIsNull));
		}
		 if(StringUtils.isNotBlank(inIsNulls)){
			criterias.add(Restrictions.in("isNull", StringUtils.split(inIsNulls, ",")));
		}
	    if(StringUtils.isNotBlank(equalDefault)){
			criterias.add(Restrictions.eq("default", equalDefault));
		}
	    if(StringUtils.isNotBlank(likeDefault)){
			criterias.add(Restrictions.allLike("default", likeDefault));
		}
		 if(StringUtils.isNotBlank(inDefaults)){
			criterias.add(Restrictions.in("default", StringUtils.split(inDefaults, ",")));
		}
	    if(StringUtils.isNotBlank(equalComment)){
			criterias.add(Restrictions.eq("comment", equalComment));
		}
	    if(StringUtils.isNotBlank(likeComment)){
			criterias.add(Restrictions.allLike("comment", likeComment));
		}
		 if(StringUtils.isNotBlank(inComments)){
			criterias.add(Restrictions.in("comment", StringUtils.split(inComments, ",")));
		}
	}
}